package com.demomaster.quickcompat.widget.button;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.demomaster.quickcompat.R;
import com.demomaster.quickcompat.widget.base.QuickView;
import com.demomaster.quickcompat.widget.base.QuickViewImpl;
import com.demomaster.quickcompat.widget.base.QuickViewUtil;

import org.jetbrains.annotations.NotNull;


public class QuickCheckBox extends androidx.appcompat.widget.AppCompatCheckBox  implements QuickView {
    public QuickCheckBox(@NonNull @NotNull Context context) {
        super(context);
        init(context, null, R.attr.QuickButton);
    }
    public QuickCheckBox(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
        super(context, attrs, R.attr.QuickButton);
        init(context, attrs, R.attr.QuickButton);
    }

    public QuickCheckBox(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs, defStyleAttr);
    }

    QuickViewImpl quickViewImpl;
    public void init(Context context, AttributeSet attrs, int defStyleAttr) {
        quickViewImpl = new QuickViewImpl(this, attrs, defStyleAttr);
        //fromAttributeSet(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        QuickViewUtil.draw(canvas,quickViewImpl);
        super.onDraw(canvas);
        QuickViewUtil.drawBadge(this,canvas,quickViewImpl);
    }
    @Override
    public void setClickable(boolean clickable) {
        super.setClickable(clickable);
        QuickViewUtil.setClickable(this);
    }

}
